<template>
	<!-- 错题/收藏 -->
	<view class="content base-con-bg">
		<nav-bar leftText="损伤、中毒的护理" leftType="5" bgColor="#FFE8CA" @tabClick="tabClick"></nav-bar>
		<question type="2" :ctindex="tabIndex" @selectCollect="selectCollect" ref="question"></question>
	</view>
</template>

<script>
	import {selectCollect } from "@/api/index.js"
	import question from '@/components/question.vue'
	export default {
		components: {
			question
		},
		data() {
			return {
				tabIndex: 0,
				pid3: '',
			}
		},
		watch: {
			
		},
		computed: {
			
		},
		onLoad() {
		
		},
		mounted() {
			this.$refs.question.getErrorAndCollectInfoByChar('2')
		},
		methods: {
			selectCollect(item,citem){
				selectCollect({
					pid3: citem.v,
					type: this.tabIndex===0 ? '2' : '1'
				}).then(res=>{
					console.log(res,'-----34')
					if(this.$common.isEmpty(res.data)){
						uni.showToast({
							title: `未查询到对应${this.tabIndex===0 ? '错题' : '收藏'}数据`,
							icon: 'none'
						})
						return
					}
					this.$store.commit('subjectByDeptUpdata',res);
					this.$store.commit('set',['isAI',false]);
					this.$store.commit('set',['isAIType','']);
					
					let params=`type=1&title=${item.n}&subtitle=${citem.n}`;
					if(this.tabIndex===1){
						params=`type=1&title=${item.n}&subtitle=${citem.n}&isOldValue=1`;
					}else{
						this.$store.commit('set',['isError',true]);
					}
					uni.navigateTo({
						url: `/pagesC/topicRelated/answerSheet?${params}`
					})
				})
			},
			tabClick(index){
				this.tabIndex=index;
				setTimeout(()=>{
					this.$refs.question.getErrorAndCollectInfoByChar('2')
				},0)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.sheet-title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 66rpx;
		padding: 0 20rpx 0 36rpx;
		font-size: 24rpx;
		color: #444;
		background-color: #F8F8F8;
		.reform{
			display: flex;
			justify-content: center;
			align-items: center;
			width: 76rpx;
			height: 40rpx;
			cursor: pointer;
			font-size: 20rpx;
			color: #487CCE;
			border-radius: 20rpx;
			border: 2rpx solid #487CCE;
		}
	}
	.type-options{
		padding: 16rpx 36rpx 4rpx;
		border-bottom: 10rpx solid #F8F8F8;
		font-size: 20rpx;
		.row{
			display: flex;
			align-items: center;
			margin-bottom: 12rpx;
		}
		.label{
			color: #999;
		}
		.type-list{
			display: flex;
		}
		.item{
			padding: 4rpx 16rpx;
			margin-right: 4rpx;
			border-radius: 20rpx;
			color: #333;
			&.on{
				background-color: #FF9813;
				color: #fff;
			}
		}
	}
	.topic-list{
		display: flex;
		flex-wrap: wrap;
		padding: 32rpx 34rpx;
		font-size: 30rpx;
		color: #333;
		.item{
			display: flex;
			justify-content: center;
			align-items: center;
			width: 82rpx;
			height: 82rpx;
			margin-right: 38rpx;
			margin-bottom: 32rpx;
			cursor: pointer;
			border-radius: 50%;
			background-color: #F8F8F8;
			&:nth-child(6n){
				margin-right: 0;
			}
			&.on1,&.on2{
				color: #fff;
			}
			&.on1{
				background-color: #48CA8C;
			}
			&.on2{
				background-color: #FD665F;
			}
		}
	}
	.statistics{
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 111;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 70rpx;
		font-size: 20rpx;
		color: #404040;
		background-color: #EFEFEF;
		.num{
			color: #50BB88;
		}
	}
</style>
